package com.hugo.maomi_first.zhuanti.view;

import android.content.Intent;
import android.os.Bundle;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.hugo.maomi_first.R;
import com.hugo.maomi_first.base.BaseMvpActivity;
import com.hugo.maomi_first.bean.ZhuanTiBean;
import com.hugo.maomi_first.bean.ZhuanTiDetailBean;
import com.hugo.maomi_first.bean.ZhuanTiHeaderBean;
import com.hugo.maomi_first.zhuanti.presenter.ZhuanTiPresenterImpl;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

public class ZhuanTiDetailActivity extends BaseMvpActivity<IZhuantiView, ZhuanTiPresenterImpl> implements IZhuantiView {


    @Bind(R.id.webView_Detail)
    WebView webViewDetail;


    @Override
    public int getLayoutId() {
        return R.layout.activity_zhuan_ti_detail;
    }

    @Override
    public void initView() {
        webViewDetail.setWebViewClient(new WebViewClient());
        webViewDetail.getSettings().setJavaScriptEnabled(true);// 支持运行javascript
        webViewDetail.setWebChromeClient(new WebChromeClient());// 支持运行特殊的javascript（例如：alert()）

//        webViewDetail.addJavascriptInterface();


        Intent intent=getIntent();
        int id =intent.getIntExtra("sub",592);
        presenter.getZhuanTiDeatail(id);

    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }

    @Override
    protected ZhuanTiPresenterImpl initPresenter() {
        return new ZhuanTiPresenterImpl();
    }

    @Override
    public void onLoadHeader(List<ZhuanTiHeaderBean.DataBean.ItemsBean> list) {

    }

    @Override
    public void onLoadDetail(List<ZhuanTiBean.DataBean.ItemsBean> list) {

    }

    @Override
    public void onLoadZhuanTiDetail(ZhuanTiDetailBean.DataBean bean) {
            webViewDetail.loadUrl(bean.getWeb_url());
    }

    @Override
    public void onFaile() {

    }
}
